package com.bblocks.common.anti_reptile.rateLimiter;



import com.bblocks.common.anti_reptile.config.bean.RuleComm;
import com.bblocks.common.anti_reptile.constant.RuleTypeEnum;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

/**
 * <p>Project: bb-anti-reptile - RateLimiterPlanDefault</p>
 * <p>描述：默认基于内存的限流方案(未实现-默认不限流)
 * </p>
 *
 * @Author Zhao [125043150@qq.com]
 * @Date 2024/3/23 14:58
 * @Version 1.0
 * @since 8
 */
@Slf4j
public class RateLimiterPlanDefault extends RateLimiterPlan {

    @Override
    public boolean tryAcquire(RuleTypeEnum ruleTypeEnum, String id, String url , long rate, long rateInterval, TimeUnit unit) {
       log.debug("直接过：{}-{}-{}-{}-{}-{}",ruleTypeEnum,id,url,rate,rateInterval,unit);
        return true;
    }

    public  boolean isBlack(RuleTypeEnum ruleTypeEnum,String id){
        return false;
    }

    /**
     * id加入黑名单
     * @param rule
     * @param id
     * @param requestUrl
     * @param time
     * @param unit
     * @return
     */
    public  int joinBlack(RuleComm rule,String id,String requestUrl, long time, TimeUnit unit){
        return 0;
    }

    public int outBlack(RuleComm rule, String id){return 0;}
}
